﻿using System.Threading;
using l1cs.server.model.Instance;

namespace l1cs.server.model
{
    class L1NpcDeleteTimer
    {
        private static Logger _log = Logger.getLogger( typeof( L1NpcDeleteTimer ).FullName );

        public L1NpcDeleteTimer( L1NpcInstance npc, int timeMillis )
        {
            _npc = npc;
            _timeMillis = timeMillis;
        }

        public void TimerSub( object state )
        {
            _npc.deleteMe();
            timer.Dispose();
        }

        public void begin()
        {
            //Timer timer = new Timer();
            //timer.schedule( this, _timeMillis );
            timer = new Timer( new TimerCallback( TimerSub ), null, _timeMillis, Timeout.Infinite );
        }

        private Timer timer;
        private L1NpcInstance _npc;
        private int _timeMillis;
    }
}
